package com.test.demo1.common;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.common.Mapper;

public abstract class BaseServiceImpl<T, ID> implements BaseService<T, ID> {
    @Autowired
    protected Mapper<T> mapper;

    public BaseServiceImpl() {
    }

    public int save(T entity) {
        return this.mapper.insertSelective(entity);
    }

    public int deleteByPrimaryKey(ID id) {
        return this.mapper.deleteByPrimaryKey(id);
    }

    public T findById(ID id) {
        return (T)this.mapper.selectByPrimaryKey(id);
    }

    public List<T> selectByExample(T t) {
        return this.mapper.selectByExample(t);
    }

    public T selectOne(T t) {
        return (T)this.mapper.selectOne(t);
    }

    public T queryById(ID t) {
        return (T)this.mapper.selectByPrimaryKey(t);
    }

    public int updateById(T t) {
        return this.mapper.updateByPrimaryKeySelective(t);
    }

    public List<T> queryAll(T t) {
        return this.mapper.select(t);
    }
}
